\subsection{Inheriting fields}\label{inher.01}

\textbf{Concept} 
Subclasses inherit all the fields of its superclasses; they can also add
fields of their own.

\prg{Inheritance01}
\prgl{inheritance}{Inheritance01}

In this simple program objects of all four classes are created and their fields
are read.
\begin{itemize}
\item The objects are created.
\item For each field of each object, a variable is declared in the main method
and the value of the field is assigned to it. Check that each value originates
from the correct field.
\end{itemize}

\textbf{Exercise} In \texttt{CParticle}, add the declaration \texttt{int
charge = -1;}. Compile and run the program. Is the output different?
Explain what happens.
